<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>17_自定义Promise</title>
</head>

<body>
  <script src="./08lib/Promise17.js"></script>
  <script>
  	const p1 = Promise.resolve(2) // 如果是一般值，p1成功，value就是这个值
  	const p2 = Promise.resolve(Promise.resolve(3)) // 如果是成功的promise，p2成功，value是这个promise的value
  	const p3 = Promise.resolve(Promise.reject(4)) // 如果是失败的promise，p3失败，reason是这个promise的reason
  	const p4 = new Promise((resolve) => {
  		setTimeout(() => {
  			resolve(5)
  		}, 1000)
  	})
  	
  	// const pAll = new Promise.all([p1, p2, p3])
  	const pAll = new Promise.all([p4, p1, p2])
  	pAll.then(
  		values => {
  			console.log('all onResolved()', values)
  		},
  		reason => {
  			console.log('all onRejected()', reason)
  		}
  	)
  </script>
</body>

</html>